package NetAPI;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPServer {
    public static void sender() throws IOException {
        DatagramSocket socket = new DatagramSocket();
        String str = "Hello, this is a message from server.";
        byte[] data = str.getBytes();
        InetAddress inet = InetAddress.getLocalHost();
        DatagramPacket packet = new DatagramPacket(data, 0,
                data.length, inet, 9090);
        socket.send(packet);
        socket.close();
    }

    public static void main(String[] args) {
        while (true) {
            try {
                Thread.sleep(300);
                sender();
            } catch (InterruptedException | IOException e) {
                e.printStackTrace();
            }
        }
    }
}
